<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>

    <meta charset="utf-8" />

    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

    <title></title>

    <link rel="stylesheet" th:href="@{/css/layui.css}" />

    <link rel="stylesheet" th:href="@{/css/main.css}" />

</head>

<body>

<!--<form class=s"layui-form" action="/jlyyj/index.php?s=/Home/Store/submit_storeinfo.html" method="post">-->
<form class="layui-form">

    <div class="goodsarg">

        <table class="layui-table" lay-skin="line">
            <tbody>
            <tr>
                <td>店铺名称</td>
                <td><input type="text" placeholder="店名（必填）" name="store_name" id="storename"/></td>
            </tr>
            <tr>
                <td>店铺类型</td>
                <td>
                    <input type="radio" name="store_Type" value="0" title="零售商" checked>
                    <input type="radio" name="store_Type" value="1" title="批发商" >
                </td>
            </tr>
            <tr>
                <td>座机电话</td>
                <td><input type="text" placeholder="座机电话" name="store_phone" id="phone"/></td>
            </tr>
            <tr>
                <td>营业执照号</td>
                <td><input type="text" placeholder="营业执照" name="store_license" id="licensenum"/></td>
            </tr>
            <tr>
                <td>备注</td>
                <td><textarea  placeholder="基本备注信息" name="store_remarks"/></textarea></td>
            </tr>
            </tbody>
        </table>
    </div>
</form>
<div class="authsave">
    <input class="auth" id="authsave" type="submit" value="保存">
</div>
<script type="text/javascript" src="/jlyyj/Public/js/layui.js" ></script>
<script type="text/javascript" src="/jlyyj/Public/js/public.js" ></script>

<script>

    layui.use('form', function(){

        var $ = layui.jquery,

            layer = layui.layer

            ,form = layui.form(); //Tab的切换功能，切换事件监听等，需要依赖element模块



//				营业执照验证

        function isCardNo(card) {

            var pattern = /(^\d{15}$)|(^\d{18}$)/;

            return pattern.test(card);

        }

//				开始各表单验证

        $("#authsave").click(function(){

            var phone = $.trim($('#phone').val());

//					var licence = $.trim($('#licensenum').val());

            var isMobile=/^(?:13\d|15\d)\d{5}(\d{3}|\*{3})$/;

            var isPhone=/^((0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/;

            if($.trim($("#storename").val()).length == 0) {

//						验证店铺名称是否为空

//						var sure = "<p>店铺名称没有输入</p>";
//
//						var value1 = "确定";
//
//						show(sure, value1);

                layer.msg('店铺名称没有输入！');

                return false;

            }else if(!phone.length == 0){

                if(!phone.match(isPhone)&&!phone.match(isMobile)){

//							var sure = "<p>座机号格式错误</p>";
//
//							var value1 = "确定";
//
//							show(sure,value1);

                    layer.msg('座机号格式错误！');

                    return false;

                }

            }


            var from_data = $('form').serializeArray();

            var url="/jlyyj/index.php?s=/Home/Store/submit_storeinfo.html";

            var index = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });

            $.ajax({

                type : "POST",

                url  : url,

                data: {from_data:from_data},

//						error: function(request) {
//
//							layer.closeAll('loading');
//
//							alert("服务器繁忙, 请联系管理员!");
//
//							return;
//
//						},

                success: function(v) {

                    layer.closeAll('loading');

                    v=JSON.parse(v);

                    if(v['code']==200){
                        layer.msg('店铺添加成功！');
                        setTimeout(function(){
                            window.location.href="/jlyyj/index.php?s=/Home/Store/storeList.html";
                        },1000)
                    }else {
                        layer.msg('店铺添加失败！');
                        setTimeout(function(){
                            window.location.reload();
                        },1000)
                    }
                }

            });

        })

    });

</script>

</body>

</html>